import * as classfyApi from '@/apis/classfy.js'

const state={
    navList:[],
    caradd:[]
};
const getters={
    ZongPrice(){
        let Zong=0
        state.caradd.forEach(item=>{
            Zong+=item.group.price * item.num
        })
        return Zong
    }
};
const mutations={
    setNavList(state,navList){
        state.navList = navList
    },
    carAdd(state,caradd){
        state.caradd.push(caradd)
    }
};
const actions={
    async getNavList(store,data){
        let res = await classfyApi.getNavList(data)
        store.commit('setNavList',res.data)
        return res
    }
};

export default{
    namespaced:true,
    state,
    getters,
    mutations,
    actions
}